package com.dys.mvvmstudy.model;

import com.dys.mvvmstudy.bean.Account;
import com.dys.mvvmstudy.callback.MCallBack;

import java.util.Random;

public class MVVMModel {

    /**
     * 查询账号数据
     * @param accountName 账号名称
     * @param mCallBack 通知用户查询结果
     */
    public void getAccountData(String accountName, MCallBack mCallBack) {
        Random random=new Random();
        boolean isSuccess = random.nextBoolean();
        if(isSuccess) {
            Account account = new Account();
            account.setName(accountName);
            account.setLevel(100);
            mCallBack.onSuccess(account);
        }else {
            mCallBack.onFailure();
        }
    }
}
